#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

ll read() {
	ll x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int S = 1 << 20;
const int N = 22;

int f[S],n,m;
ll s[S],a[N];

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in; for(int i = 1;i <= n;i++) a[i] = in; for(int i = 1;i <= n;i++) if(a[i] != 0) a[++m] = a[i]; n = m;
	int U = 1 << n; for(int i = 1;i <= n;i++) s[1 << (i - 1)] = a[i];
	for(int i = 1;i < U;i++) s[i] = s[i ^ (i & -i)] + s[i & -i],f[i] = f[i ^ (i & -i)] + 1;
	for(int i = 1;i < U;i++) {
		if((s[i] - f[i] + 1) & 1) continue;
		for(int t = (i - 1) & i;t;t = (t - 1) & i) 
			if(llabs(s[i ^ t] - s[t]) < f[i]) {f[i] = f[i] - 1; break;}
	}
	for(int i = 1;i < U;i++)
		for(int t = (i - 1) & i;t;t = (t - 1) & i) f[i] = min(f[i],f[i ^ t] + f[t]);
	printf("%d\n",f[U - 1]);
	return 0;
}
